package lily.phs.object;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import lily.phs.database.Constants;
/**
 * 精神疾病患者个人信息补充表---数据封装类
 * @author heck
 *
 */
public class MentalerInfo implements Constants {
	
	private Context mContext;
	
	private int mein_profileid = -1;
    private String mein_guardian_name = "";
    private String mein_guardian_relation = "";
    private String mein_guardian_address = "";
    private String mein_guardian_phone = "";
    private String mein_neighbor_name = "";
    private String mein_neighbor_phone = "";
    private int mein_approved = -1;
    private String mein_self_signature = "";
    private String mein_self_signature_time = "";
    private String mein_first_occur_time = "";
    private String mein_past_symptoms = "";
    private String mein_past_symptoms_other = "";
    private int mein_clinic = -1;
    private String mein_first_treat_time = "";
    private int mein_hospital_times = -1;
    private String mein_current_state = "";
    private String mein_diagnose_hospital = "";
    private String mein_diagnose_time = "";
    private int mein_recent_treatment = -1;
    private String mein_influence = "";
    private int mein_influ_trouble = -1;
    private int mein_influ_accident = -1;
    private int mein_influ_disaster = -1;
    private int mein_influ_injure = -1;
    private int mein_influ_suicide = -1;
    private int mein_lock = -1;
    private int mein_economy = -1;
    private String mein_advices = "";
    private String mein_date = "";
    private String mein_doctor = "";
    
    
	public MentalerInfo(Context context) {
		this.mContext = context;
	}


	public int getMein_profileid() {
		return mein_profileid;
	}


	public void setMein_profileid(int mein_profileid) {
		this.mein_profileid = mein_profileid;
	}


	public String getMein_guardian_name() {
		return mein_guardian_name;
	}


	public void setMein_guardian_name(String mein_guardian_name) {
		this.mein_guardian_name = mein_guardian_name;
	}


	public String getMein_guardian_relation() {
		return mein_guardian_relation;
	}


	public void setMein_guardian_relation(String mein_guardian_relation) {
		this.mein_guardian_relation = mein_guardian_relation;
	}


	public String getMein_guardian_address() {
		return mein_guardian_address;
	}


	public void setMein_guardian_address(String mein_guardian_address) {
		this.mein_guardian_address = mein_guardian_address;
	}


	public String getMein_guardian_phone() {
		return mein_guardian_phone;
	}


	public void setMein_guardian_phone(String mein_guardian_phone) {
		this.mein_guardian_phone = mein_guardian_phone;
	}


	public String getMein_neighbor_name() {
		return mein_neighbor_name;
	}


	public void setMein_neighbor_name(String mein_neighbor_name) {
		this.mein_neighbor_name = mein_neighbor_name;
	}


	public String getMein_neighbor_phone() {
		return mein_neighbor_phone;
	}


	public void setMein_neighbor_phone(String mein_neighbor_phone) {
		this.mein_neighbor_phone = mein_neighbor_phone;
	}


	public int getMein_approved() {
		return mein_approved;
	}


	public void setMein_approved(int mein_approved) {
		this.mein_approved = mein_approved;
	}


	public String getMein_self_signature() {
		return mein_self_signature;
	}


	public void setMein_self_signature(String mein_self_signature) {
		this.mein_self_signature = mein_self_signature;
	}


	public String getMein_self_signature_time() {
		return mein_self_signature_time;
	}


	public void setMein_self_signature_time(String mein_self_signature_time) {
		this.mein_self_signature_time = mein_self_signature_time;
	}


	public String getMein_first_occur_time() {
		return mein_first_occur_time;
	}


	public void setMein_first_occur_time(String mein_first_occur_time) {
		this.mein_first_occur_time = mein_first_occur_time;
	}


	public String getMein_past_symptoms() {
		return mein_past_symptoms;
	}


	public void setMein_past_symptoms(String mein_past_symptoms) {
		this.mein_past_symptoms = mein_past_symptoms;
	}


	public String getMein_past_symptoms_other() {
		return mein_past_symptoms_other;
	}


	public void setMein_past_symptoms_other(String mein_past_symptoms_other) {
		this.mein_past_symptoms_other = mein_past_symptoms_other;
	}


	public int getMein_clinic() {
		return mein_clinic;
	}


	public void setMein_clinic(int mein_clinic) {
		this.mein_clinic = mein_clinic;
	}


	public String getMein_first_treat_time() {
		return mein_first_treat_time;
	}


	public void setMein_first_treat_time(String mein_first_treat_time) {
		this.mein_first_treat_time = mein_first_treat_time;
	}


	public int getMein_hospital_times() {
		return mein_hospital_times;
	}


	public void setMein_hospital_times(int mein_hospital_times) {
		this.mein_hospital_times = mein_hospital_times;
	}


	public String getMein_current_state() {
		return mein_current_state;
	}


	public void setMein_current_state(String mein_current_state) {
		this.mein_current_state = mein_current_state;
	}


	public String getMein_diagnose_hospital() {
		return mein_diagnose_hospital;
	}


	public void setMein_diagnose_hospital(String mein_diagnose_hospital) {
		this.mein_diagnose_hospital = mein_diagnose_hospital;
	}


	public String getMein_diagnose_time() {
		return mein_diagnose_time;
	}


	public void setMein_diagnose_time(String mein_diagnose_time) {
		this.mein_diagnose_time = mein_diagnose_time;
	}


	public int getMein_recent_treatment() {
		return mein_recent_treatment;
	}


	public void setMein_recent_treatment(int mein_recent_treatment) {
		this.mein_recent_treatment = mein_recent_treatment;
	}


	public String getMein_influence() {
		return mein_influence;
	}


	public void setMein_influence(String mein_influence) {
		this.mein_influence = mein_influence;
	}


	public int getMein_influ_trouble() {
		return mein_influ_trouble;
	}


	public void setMein_influ_trouble(int mein_influ_trouble) {
		this.mein_influ_trouble = mein_influ_trouble;
	}


	public int getMein_influ_accident() {
		return mein_influ_accident;
	}


	public void setMein_influ_accident(int mein_influ_accident) {
		this.mein_influ_accident = mein_influ_accident;
	}


	public int getMein_influ_disaster() {
		return mein_influ_disaster;
	}


	public void setMein_influ_disaster(int mein_influ_disaster) {
		this.mein_influ_disaster = mein_influ_disaster;
	}


	public int getMein_influ_injure() {
		return mein_influ_injure;
	}


	public void setMein_influ_injure(int mein_influ_injure) {
		this.mein_influ_injure = mein_influ_injure;
	}


	public int getMein_influ_suicide() {
		return mein_influ_suicide;
	}


	public void setMein_influ_suicide(int mein_influ_suicide) {
		this.mein_influ_suicide = mein_influ_suicide;
	}


	public int getMein_lock() {
		return mein_lock;
	}


	public void setMein_lock(int mein_lock) {
		this.mein_lock = mein_lock;
	}


	public int getMein_economy() {
		return mein_economy;
	}


	public void setMein_economy(int mein_economy) {
		this.mein_economy = mein_economy;
	}


	public String getMein_advices() {
		return mein_advices;
	}


	public void setMein_advices(String mein_advices) {
		this.mein_advices = mein_advices;
	}


	public String getMein_date() {
		return mein_date;
	}


	public void setMein_date(String mein_date) {
		this.mein_date = mein_date;
	}


	public String getMein_doctor() {
		return mein_doctor;
	}


	public void setMein_doctor(String mein_doctor) {
		this.mein_doctor = mein_doctor;
	}

	/**
	 * 查找并初始化当前对象
	 */
	public void selectMentalerInfo(int id){
		String where = MEIN_PROFILEID + "=" + id;
		Cursor cursor = mContext.getContentResolver().query(CONTENT_URI_TB23, null, where, null, null);
		while(cursor.moveToNext()){
			this.mein_profileid = cursor.getInt(cursor.getColumnIndex(MEIN_PROFILEID));
		    this.mein_guardian_name = cursor.getString(cursor.getColumnIndex(MEIN_GUARDIAN_NAME));
		    this.mein_guardian_relation = cursor.getString(cursor.getColumnIndex(MEIN_GUARDIAN_RELATION));
		    this.mein_guardian_address = cursor.getString(cursor.getColumnIndex(MEIN_GUARDIAN_ADDRESS));
		    this.mein_guardian_phone = cursor.getString(cursor.getColumnIndex(MEIN_GUARDIAN_PHONE));
		    this.mein_neighbor_name = cursor.getString(cursor.getColumnIndex(MEIN_NEIGHBOR_NAME));
		    this.mein_neighbor_phone = cursor.getString(cursor.getColumnIndex(MEIN_NEIGHBOR_PHONE));
		    this.mein_approved = cursor.getInt(cursor.getColumnIndex(MEIN_APPROVED));
		    this.mein_self_signature = cursor.getString(cursor.getColumnIndex(MEIN_SELF_SIGNATURE));
		    this.mein_self_signature_time = cursor.getString(cursor.getColumnIndex(MEIN_SELF_SIGNATURE_TIME));
		    this.mein_first_occur_time = cursor.getString(cursor.getColumnIndex(MEIN_FIRST_OCCUR_TIME));
		    this.mein_past_symptoms = cursor.getString(cursor.getColumnIndex(MEIN_PAST_SYMPTOMS));
		    this.mein_past_symptoms_other = cursor.getString(cursor.getColumnIndex(MEIN_PAST_SYMPTOMS_OTHER));
		    this.mein_clinic = cursor.getInt(cursor.getColumnIndex(MEIN_CLINIC));
		    this.mein_first_treat_time = cursor.getString(cursor.getColumnIndex(MEIN_FIRST_TREAT_TIME));
		    this.mein_hospital_times = cursor.getInt(cursor.getColumnIndex(MEIN_HOSPITAL_TIMES));
		    this.mein_current_state = cursor.getString(cursor.getColumnIndex(MEIN_CURRENT_STATE));
		    this.mein_diagnose_hospital = cursor.getString(cursor.getColumnIndex(MEIN_DIAGNOSE_HOSPITAL));
		    this.mein_diagnose_time = cursor.getString(cursor.getColumnIndex(MEIN_DIAGNOSE_TIME));
		    this.mein_recent_treatment = cursor.getInt(cursor.getColumnIndex(MEIN_RECENT_TREATMENT));
		    this.mein_influence = cursor.getString(cursor.getColumnIndex(MEIN_INFLUENCE));
		    this.mein_influ_trouble = cursor.getInt(cursor.getColumnIndex(MEIN_INFLU_TROUBLE));
		    this.mein_influ_accident = cursor.getInt(cursor.getColumnIndex(MEIN_INFLU_ACCIDENT));
		    this.mein_influ_disaster = cursor.getInt(cursor.getColumnIndex(MEIN_INFLU_DISASTER));
		    this.mein_influ_injure = cursor.getInt(cursor.getColumnIndex(MEIN_INFLU_INJURE));
		    this.mein_influ_suicide = cursor.getInt(cursor.getColumnIndex(MEIN_INFLU_SUICIDE));
		    this.mein_lock = cursor.getInt(cursor.getColumnIndex(MEIN_LOCK));
		    this.mein_economy = cursor.getInt(cursor.getColumnIndex(MEIN_ECONOMY));
		    this.mein_advices = cursor.getString(cursor.getColumnIndex(MEIN_ADVICES));
		    this.mein_date = cursor.getString(cursor.getColumnIndex(MEIN_DATE));
		    this.mein_doctor = cursor.getString(cursor.getColumnIndex(MEIN_DOCTOR));
		}
		cursor.close();
		
	}
	
	/**
	 * 将当前对象插入数据库
	 */
    public void insertMentalerInfo(){
    	ContentValues value = new ContentValues();
    	value.put(MEIN_PROFILEID , this.getMein_profileid());
        value.put(MEIN_GUARDIAN_NAME , this.getMein_guardian_name());
        value.put(MEIN_GUARDIAN_RELATION ,  this.getMein_guardian_relation());
        value.put(MEIN_GUARDIAN_ADDRESS , this.getMein_guardian_address());
        value.put(MEIN_GUARDIAN_PHONE ,  this.getMein_guardian_phone());
        value.put(MEIN_NEIGHBOR_NAME ,  this.getMein_neighbor_name());
        value.put(MEIN_NEIGHBOR_PHONE ,  this.getMein_neighbor_phone());
        value.put(MEIN_APPROVED ,  this.getMein_approved());
        value.put(MEIN_SELF_SIGNATURE ,  this.getMein_self_signature());
        value.put(MEIN_SELF_SIGNATURE_TIME , this.getMein_self_signature_time());
        value.put(MEIN_FIRST_OCCUR_TIME ,  this.getMein_first_occur_time());
        value.put(MEIN_PAST_SYMPTOMS , this.getMein_past_symptoms());
        value.put(MEIN_PAST_SYMPTOMS_OTHER ,  this.getMein_past_symptoms_other());
        value.put(MEIN_CLINIC , this.getMein_clinic());
        value.put(MEIN_FIRST_TREAT_TIME , this.getMein_first_treat_time());
        value.put(MEIN_HOSPITAL_TIMES ,  this.getMein_hospital_times());
        value.put(MEIN_CURRENT_STATE ,  this.getMein_current_state());
        value.put(MEIN_DIAGNOSE_HOSPITAL ,  this.getMein_diagnose_hospital());
        value.put(MEIN_DIAGNOSE_TIME ,  this.getMein_diagnose_time());
        value.put(MEIN_RECENT_TREATMENT ,  this.getMein_recent_treatment());
        value.put(MEIN_INFLUENCE ,  this.getMein_influence());
        value.put(MEIN_INFLU_TROUBLE ,  this.getMein_influ_trouble());
        value.put(MEIN_INFLU_ACCIDENT ,  this.getMein_influ_accident());
        value.put(MEIN_INFLU_DISASTER ,  this.getMein_influ_disaster());
        value.put(MEIN_INFLU_INJURE ,  this.getMein_influ_injure());
        value.put(MEIN_INFLU_SUICIDE ,  this.getMein_influ_suicide());
        value.put(MEIN_LOCK ,  this.getMein_lock());
        value.put(MEIN_ECONOMY ,  this.getMein_economy());
        value.put(MEIN_ADVICES ,  this.getMein_advices());
        value.put(MEIN_DATE ,  this.getMein_date());
        value.put(MEIN_DOCTOR ,  this.getMein_doctor());
    	
    	this.mContext.getContentResolver().insert(CONTENT_URI_TB23, value);
    }
    
    /**
     * 将当前对象的数据更新至数据库
     */
    public void updateMentalerInfo(int id){
    	ContentValues value = new ContentValues();
    	value.put(MEIN_PROFILEID , this.getMein_profileid());
        value.put(MEIN_GUARDIAN_NAME , this.getMein_guardian_name());
        value.put(MEIN_GUARDIAN_RELATION ,  this.getMein_guardian_relation());
        value.put(MEIN_GUARDIAN_ADDRESS , this.getMein_guardian_address());
        value.put(MEIN_GUARDIAN_PHONE ,  this.getMein_guardian_phone());
        value.put(MEIN_NEIGHBOR_NAME ,  this.getMein_neighbor_name());
        value.put(MEIN_NEIGHBOR_PHONE ,  this.getMein_neighbor_phone());
        value.put(MEIN_APPROVED ,  this.getMein_approved());
        value.put(MEIN_SELF_SIGNATURE ,  this.getMein_self_signature());
        value.put(MEIN_SELF_SIGNATURE_TIME , this.getMein_self_signature_time());
        value.put(MEIN_FIRST_OCCUR_TIME ,  this.getMein_first_occur_time());
        value.put(MEIN_PAST_SYMPTOMS , this.getMein_past_symptoms());
        value.put(MEIN_PAST_SYMPTOMS_OTHER ,  this.getMein_past_symptoms_other());
        value.put(MEIN_CLINIC , this.getMein_clinic());
        value.put(MEIN_FIRST_TREAT_TIME , this.getMein_first_treat_time());
        value.put(MEIN_HOSPITAL_TIMES ,  this.getMein_hospital_times());
        value.put(MEIN_CURRENT_STATE ,  this.getMein_current_state());
        value.put(MEIN_DIAGNOSE_HOSPITAL ,  this.getMein_diagnose_hospital());
        value.put(MEIN_DIAGNOSE_TIME ,  this.getMein_diagnose_time());
        value.put(MEIN_RECENT_TREATMENT ,  this.getMein_recent_treatment());
        value.put(MEIN_INFLUENCE ,  this.getMein_influence());
        value.put(MEIN_INFLU_TROUBLE ,  this.getMein_influ_trouble());
        value.put(MEIN_INFLU_ACCIDENT ,  this.getMein_influ_accident());
        value.put(MEIN_INFLU_DISASTER ,  this.getMein_influ_disaster());
        value.put(MEIN_INFLU_INJURE ,  this.getMein_influ_injure());
        value.put(MEIN_INFLU_SUICIDE ,  this.getMein_influ_suicide());
        value.put(MEIN_LOCK ,  this.getMein_lock());
        value.put(MEIN_ECONOMY ,  this.getMein_economy());
        value.put(MEIN_ADVICES ,  this.getMein_advices());
        value.put(MEIN_DATE ,  this.getMein_date());
        value.put(MEIN_DOCTOR ,  this.getMein_doctor());

		String where = MEIN_PROFILEID + "=" + id;
		mContext.getContentResolver().update(CONTENT_URI_TB23, value, where, null);
    }
    
    /**
     * 删除数据库中的记录
     */
    public void deleteMentalerInfo(int id){
		String where = MEIN_PROFILEID + "=" + id;
    	mContext.getContentResolver().delete(CONTENT_URI_TB23, where, null);
    }
    
}
